package com.example.myapplication.chap02;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;

public class SecondActivity extends AppCompatActivity {

    private Button bt_colse = null;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_02_second);
        bt_colse = findViewById(R.id.button_close);
        bt_colse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent in = getIntent();
                in.putExtra("result_str","我是物联网");
                setResult(RESULT_OK,in);
                finish();
            }
        });
        Intent intent = getIntent();
        String str = intent.getStringExtra("ed");
        TextView tv = findViewById(R.id.text_second);
        tv.setText("收到 : "+str);
        Log.v("SecondActivity",str);

    }
}
